package zhongbo.java.air.airflightpath.web;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhongbo.java.air.airflightpath.model.FlightPath;
import zhongbo.java.air.airflightpath.service.AirFlightPathService;
import zhongbo.java.air.common.vo.PageVo;
import zhongbo.java.air.common.vo.ResultVo;

@RestController
@RequestMapping("/flight")
@Api(tags = "航迹服务")
public class AirFlightPathController {
    @Autowired
    AirFlightPathService airFlightPathService;


    @PostMapping("/added")
    @ApiOperation("航迹服务添加")
    public ResultVo<FlightPath> add(@RequestBody FlightPath flightPath){
       FlightPath add= airFlightPathService.add(flightPath);
        return ResultVo.ok(add);
    }

    @PostMapping("/delete")
    @ApiOperation("删除航迹")
    public ResultVo<String> delete(String id){
     String delete =   airFlightPathService.delete(id);
        return ResultVo.ok(delete);
    }

    @PostMapping("/select")
    @ApiOperation("更新航迹")
    public ResultVo<FlightPath> update(@RequestBody FlightPath flightPath){
        FlightPath update =airFlightPathService.update(flightPath);
        return ResultVo.ok(update);
    }

    @PostMapping("/selectPage")
    @ApiOperation("查询")
    public ResultVo<FlightPath> select(String id){
        FlightPath select =airFlightPathService.select(id);
        return ResultVo.ok(select);
    }


    @ResponseBody
    @GetMapping ("/分页查询")
    @ApiOperation("分页查询")
    public ResultVo<PageVo<FlightPath>> page(@RequestParam(required = false) String id,
                                             @RequestParam(required = false,defaultValue = "1")int pageNumber,
                                             @RequestParam(required = false,defaultValue = "10") int pageSize){
        PageVo<FlightPath> pageVo =airFlightPathService.page(id,pageNumber,pageSize);
        return  ResultVo.ok(pageVo);
    }
}
